class SimpLineChart {
  constructor() {
    // this.themeColor = ['#00DEFF', '#FFBE00', '#32ACFF', '#06CB82']
    this.option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          crossStyle: {
            color: '#999',
          },
        },
      },
      //   toolbox: {
      //     feature: {
      //       dataView: { show: true, readOnly: false },
      //       magicType: { show: true, type: ['line', 'bar'] },
      //       restore: { show: true },
      //       saveAsImage: { show: true },
      //     },
      //   },
      legend: {
        data: ['保费占比', '手续费率', '边际成本率', '自主折扣率'],
      },
      xAxis: [
        {
          type: 'category',
          data: [],
          axisLabel: {
            interval: 0,
            rotate: 30,
            fontSize: 10,
          },
          axisPointer: {
            type: 'shadow',
          },
        },
      ],
      yAxis: [
        {
          type: 'value',
          name: '边际成本率/自主折扣率/手续费率',
          // min: 0,
          // max: 0,
          // interval: 0,
          axisLabel: {
            formatter: '{value}%',
          },
          nameTextStyle: {
            align: 'left',
            padding: [0, 0, 0, -20],
          },
        },
        {
          type: 'value',
          name: '保费占比',
          // min: 0,
          // max: 0,
          // interval: 0,
          axisLabel: {
            formatter: '{value}%',
          },
        },
      ],
      series: [
        {
          name: '保费占比',
          type: 'bar', // 柱状
          yAxisIndex: 1, // 用第二个y轴
          data: [],
        },
        {
          name: '手续费率',
          type: 'line',
          yAxisIndex: 0, // 用第1个y轴
          data: [],
        },
        {
          name: '边际成本率',
          type: 'line', // 折线
          yAxisIndex: 0,
          data: [],
        },
        {
          name: '自主折扣率',
          type: 'line', // 折线
          yAxisIndex: 0,
          data: [],
        },
      ],
    };
  }

  setData() {
    let list = [
      {
        riskcategory2: '01.(0,30%]',
        propPremium: '4.02',
        marginalCost: '29.08',
        discountRate: '94.78',
        commissionRate: '7.94',
        effectScore: '6.32',
      },
      {
        riskcategory2: '02.(30,35%]',
        propPremium: '1.34',
        marginalCost: '42.67',
        discountRate: '94.65',
        commissionRate: '8.40',
        effectScore: '6.32',
      },
      {
        riskcategory2: '03.(35%,40%]',
        propPremium: '3.98',
        marginalCost: '44.79',
        discountRate: '98.27',
        commissionRate: '6.39',
        effectScore: '6.32',
      },
      {
        riskcategory2: '04.(40%,45%]',
        propPremium: '3.21',
        marginalCost: '51.56',
        discountRate: '97.10',
        commissionRate: '7.81',
        effectScore: '6.32',
      },
      {
        riskcategory2: '05.(45%,50%]',
        propPremium: '3.81',
        marginalCost: '56.06',
        discountRate: '98.81',
        commissionRate: '7.94',
        effectScore: '6.32',
      },
      {
        riskcategory2: '06.(50%,55%]',
        propPremium: '6.91',
        marginalCost: '62.80',
        discountRate: '98.99',
        commissionRate: '9.53',
        effectScore: '6.32',
      },
      {
        riskcategory2: '07.(55%,60%]',
        propPremium: '6.48',
        marginalCost: '73.67',
        discountRate: '94.97',
        commissionRate: '13.47',
        effectScore: '6.32',
      },
      {
        riskcategory2: '08.(60%,65%]',
        propPremium: '7.64',
        marginalCost: '79.24',
        discountRate: '95.67',
        commissionRate: '14.02',
        effectScore: '6.32',
      },
      {
        riskcategory2: '09.(65%,70%]',
        propPremium: '11.43',
        marginalCost: '82.91',
        discountRate: '96.58',
        commissionRate: '12.78',
        effectScore: '6.32',
      },
      {
        riskcategory2: '10.(70%,75%]',
        propPremium: '7.32',
        marginalCost: '82.77',
        discountRate: '98.21',
        commissionRate: '9.40',
        effectScore: '6.32',
      },
      {
        riskcategory2: '11.(75%,80%]',
        propPremium: '7.23',
        marginalCost: '89.74',
        discountRate: '98.06',
        commissionRate: '10.41',
        effectScore: '6.32',
      },
      {
        riskcategory2: '12.(80%,85%]',
        propPremium: '5.88',
        marginalCost: '95.80',
        discountRate: '96.63',
        commissionRate: '10.59',
        effectScore: '6.32',
      },
      {
        riskcategory2: '13.(85%,90%]',
        propPremium: '4.93',
        marginalCost: '96.45',
        discountRate: '103.43',
        commissionRate: '11.45',
        effectScore: '6.32',
      },
      {
        riskcategory2: '14.(90%,95%]',
        propPremium: '6.32',
        marginalCost: '99.90',
        discountRate: '98.61',
        commissionRate: '7.21',
        effectScore: '6.32',
      },
      {
        riskcategory2: '15.(95%,100%]',
        propPremium: '3.10',
        marginalCost: '108.06',
        discountRate: '97.56',
        commissionRate: '8.46',
        effectScore: '6.32',
      },
      {
        riskcategory2: '16.(100%,105%]',
        propPremium: '2.86',
        marginalCost: '108.66',
        discountRate: '99.11',
        commissionRate: '6.38',
        effectScore: '6.32',
      },
      {
        riskcategory2: '17.(105%,110%]',
        propPremium: '1.13',
        marginalCost: '123.73',
        discountRate: '95.72',
        commissionRate: '11.60',
        effectScore: '6.32',
      },
      {
        riskcategory2: '18.(110%,115%]',
        propPremium: '1.33',
        marginalCost: '128.34',
        discountRate: '97.12',
        commissionRate: '12.39',
        effectScore: '6.32',
      },
      {
        riskcategory2: '19.(115%,120%]',
        propPremium: '1.09',
        marginalCost: '124.07',
        discountRate: '101.41',
        commissionRate: '8.03',
        effectScore: '6.32',
      },
      {
        riskcategory2: '20.(120%,125%]',
        propPremium: '1.18',
        marginalCost: '125.81',
        discountRate: '102.33',
        commissionRate: '6.47',
        effectScore: '6.32',
      },
      {
        riskcategory2: '21.(125%,130%]',
        propPremium: '0.88',
        marginalCost: '132.77',
        discountRate: '102.96',
        commissionRate: '8.92',
        effectScore: '6.32',
      },
      {
        riskcategory2: '22.(130%,135%]',
        propPremium: '0.85',
        marginalCost: '138.23',
        discountRate: '99.80',
        commissionRate: '5.90',
        effectScore: '6.32',
      },
      {
        riskcategory2: '23.(135%,140%]',
        propPremium: '0.74',
        marginalCost: '134.49',
        discountRate: '107.91',
        commissionRate: '7.13',
        effectScore: '6.32',
      },
      {
        riskcategory2: '24.(140%,145%]',
        propPremium: '1.46',
        marginalCost: '144.33',
        discountRate: '100.30',
        commissionRate: '3.15',
        effectScore: '6.32',
      },
      {
        riskcategory2: '25.(145%,150%]',
        propPremium: '0.72',
        marginalCost: '153.69',
        discountRate: '98.27',
        commissionRate: '4.60',
        effectScore: '6.32',
      },
      {
        riskcategory2: '26.(150%,HIGH]',
        propPremium: '4.17',
        marginalCost: '195.90',
        discountRate: '100.46',
        commissionRate: '4.32',
        effectScore: '6.32',
      },
    ];
    let list1 = []; let list2 = []; let list3 = []; let list4 = []; let list234 = []; let feizhenumlist = [];
    list.forEach((el) => {
      this.score = el.effectScore;
      feizhenumlist.push(el.riskcategory2);
      list1.push(el.propPremium); // 保费占比
      list2.push(el.commissionRate); // 手续费率
      list3.push(el.marginalCost); // 边际成本率
      list4.push(el.discountRate); // 自主折扣率
      list234.push(el.commissionRate, el.marginalCost, el.discountRate);
    });
    let num1 = Math.max.apply(null, list1);
    let num2 = Math.max.apply(null, list234);
    num1 = Math.ceil(num1 / 5) * 5;
    num2 = Math.ceil(num2 / 5) * 5;

    this.option.xAxis[0].data = feizhenumlist;
    this.option.yAxis[0].max = num2;
    this.option.yAxis[0].interval = num2 / 5;
    this.option.yAxis[1].max = num1;
    this.option.yAxis[1].interval = num1 / 5;
    this.option.series[0].data = list1;
    this.option.series[1].data = list2;
    this.option.series[2].data = list3;
    this.option.series[3].data = list4;
  }
}
export default new SimpLineChart();
